#include "./engine.h"

int   mds_engine_load( mds_engine *engine, size_t num_particles )
{
	mds_uvector pbc = { 1, 1, 1 };
	assert( NULL != engine );
	assert(num_particles>0);
	
	if( mds_frame_load( & engine->frame, num_particles, engine->step.num_sets ) < 0 )
		return -1;
	
	if( mds_cells_load( &engine->cells, & engine->frame.box, engine->cutout ) < 0 )
	{
		goto ERROR;
	}
	
	
	mds_cells_link( & engine->cells, &pbc );
	
	return 0;
	
ERROR:
	mds_engine_quit( engine );
	return -1;
}

void  mds_engine_quit( mds_engine *engine )
{
	assert( NULL != engine );
	
	mds_cells_quit( & engine->cells );
	mds_frame_quit( & engine->frame );
}
